package com.example.backend.service;


import com.example.backend.entity.Dishes;
import com.example.backend.entity.Shop;
import com.example.backend.mapper.DishesMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Service
public class DishesService {
    @Autowired
    private DishesMapper dishesMapper;

    public int addDishes(Dishes dishes) {
        dishes.setState("1");
        return dishesMapper.addDishes(dishes);
    }

    public int deleteDishesById(Serializable id) {
        return dishesMapper.deleteDishesById(id);
    }

    public int updateDishes(Dishes dishes) {
        return dishesMapper.updateDishes(dishes);
    }

    public Dishes selectDishesById(Serializable id) {
        return dishesMapper.selectDishesById(id);
    }

    public ArrayList<Dishes> selectDishes(Dishes dishes) {
        return dishesMapper.selectDishes(dishes);
    }
    public ArrayList<Dishes> selectDishesByShopId(String shop_id) {
        return dishesMapper.selectDishesByShopId(shop_id);
    }


    public PageInfo<Dishes> dishesGetPage(Integer pageNum, Integer pageSize, Dishes  dishes) {
        PageHelper.startPage(pageNum, pageSize);
        List<Dishes> list = dishesMapper.selectDishes(dishes);
        return new PageInfo<>(list);
    }

}
